package top.luckyluxcis.api;

import lombok.experimental.UtilityClass;
import top.luckyluxcis.RollApi;
import top.luckyluxcis.consts.LotteryCode;
import top.luckyluxcis.type.Lottery;
import top.luckyluxcis.type.LotteryCheck;
import top.luckyluxcis.type.LotteryType;
import top.luckyluxcis.util.MapUtil;

import java.util.List;
import java.util.Map;

/**多彩种中奖信息查询，每日更新
 * @author Zhuang
 * @since 2023/9/21
 */
@SuppressWarnings("unused")
@UtilityClass
public class LotteryUtil {
    private static final RollApi API = RollApi.getInstance();

    /**
     * 获取指定期号的通用获奖号码信息
     *
     * @param expect 彩票期号必传
     * @param code   彩票种类标识，目前提供七种彩种， ssq：双色球，qlc：七乐彩，fc3d：福彩3D，cjdlt：超级大乐透，qxc：七星彩，pl3：排列3，pl5：排列(5)
     * @return {@link Lottery}
     */
    public static Lottery commonAimLottery(String expect, LotteryCode code) {
        Map<String, Object> params = MapUtil.<String, Object>builder()
                .put("expect", expect)
                .put("code", code)
                .build();
        return API.get("/lottery/common/aim_lottery", params, Lottery.class);
    }

    /**
     * 获取最新通用中奖号码信息
     *
     * @param code 彩票种类标识，目前提供七种彩种，ssq：双色球，qlc：七乐彩，fc3d：福彩3D，cjdlt：超级大乐透，qxc：七星彩，pl3：排列3，pl5：排列(5)
     * @return {@link Lottery}
     */
    public static Lottery commonLast(LotteryCode code) {
        Map<String, Object> params = MapUtil.<String, Object>builder()
                .put("code", code)
                .build();
        return API.get("/lottery/common/latest", params, Lottery.class);
    }

    /**
     * 获取最近历史开奖数据
     *
     * @param size 获取历史数据的条数，最多50条
     * @param code 彩票种类标识，目前提供七种彩种，ssq：双色球，qlc：七乐彩，fc3d：福彩3D，cjdlt：超级大乐透，qxc：七星彩，pl3：排列3，pl5：排列(5)
     * @return {@link List}<{@link Lottery}>
     */
    public static List<Lottery> commonHistory(Integer size, LotteryCode code) {
        Map<String, Object> params = MapUtil.<String, Object>builder()
                .put("size", size)
                .put("code", code)
                .build();
        return API.get("/lottery/common/history", params, List.class);
    }

    /**
     * 获取系统支持的彩种类型详细信息
     *
     * @return {@link List<LotteryType>}
     */
    public static List<LotteryType> commonTypes() {
        return API.get("/lottery/common/types", MapUtil.empty(), List.class);
    }

    /**
     * 获取彩票的中奖结果，根据投注的彩票号码及期数判断是否中奖，暂只支持双色球、大乐透、七乐彩和七星彩；结果根据一定算法进行计算，如有偏差，请以官方为准！
     *
     * @param expect    彩票期号
     * @param lotteryNo 购买的号码，号码之间用英文逗号隔开，红色球和蓝色求之间用@连接，例如：13,19,28,30,33@02,12
     * @param code      彩票种类标识，目前提供七种彩种，ssq：双色球，qlc：七乐彩，fc3d：福彩3D，cjdlt：超级大乐透，qxc：七星彩，pl3：排列3，pl5：排列(5)
     * @return {@link LotteryCheck}
     */
    public static LotteryCheck commonCheck(String expect,String lotteryNo,LotteryCode code){
        Map<String, Object> params = MapUtil.<String, Object>builder()
                .put("expect", expect)
                .put("lotteryNo", lotteryNo)
                .put("code", code)
                .build();
        return API.get("/lottery/common/check", params, LotteryCheck.class);
    }
}
